<?php
session_start();

$error = false;

if((!isset($_SESSION["user"]))||(!isset($_SESSION["type"])))
	$error = true;

if(($_SESSION["type"] != "admin")||($_SESSION["user"] == ""))
	$error = true;

if($error)
{
	session_unset();
	session_destroy();

	header("Location: login.php");
	exit;
}

require("include/config.inc.php");

@chmod("backups/", 0777);

$file = "backups/" . DB_NAME . "_" . date("Y-m-d_H-i-s") . ".gz";
$command = "mysqldump --opt -h " . DB_HOST ." -u " . DB_USER . " -p " . DB_PASSWORD . " " . DB_NAME . " | gzip > $file";
system($command);
	
header("Location: admin_opt.php");
exit;
?>